/**
 * 初始化字典详情对话框
 */
var DicConfig = {
    count: $("#itemSize").val(),
    dictName: '',			//字典的名称
    disTypeNo:'',
    mutiString: '',		//拼接字符串内容(拼接字典条目)
    itemTemplate: $("#itemTemplate").html()
};
/**
 * 清除为空的item Dom
 */
DicConfig.clearNullDom = function(){
    $("[name='dictItem']").each(function(){
        var num = $(this).find("[name='itemValue']").val();
        var name = $(this).find("[name='itemName']").val();
        if(num == '' || name == ''){
            $(this).remove();
        }
    });
};


/**
 * 收集添加字典的数据
 */
DicConfig.collectData = function () {
    this.clearNullDom();
    var mutiString = "";
    $("[name='dictItem']").each(function(){
        var value = $(this).find("[name='itemValue']").val();
        var code = $(this).find("[name='itemCode']").val();
        var name = $(this).find("[name='itemName']").val();
        mutiString = mutiString + (code + "々" + value +"々"+ name + ";");
    });
    this.dictName = $("#dictName").val();
    this.disTypeNo = $("#disTypeNo").val();
    this.mutiString = mutiString;
};



/**
 * 提交修改
 */
DicConfig.editSubmit = function () {
    this.collectData();
    var ajax = new $ax(Feng.ctxPath + "/dic/update", function (data) {
        Feng.success("修改成功!");
    }, function (data) {
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set('dictId',$("#dictId").val());
    ajax.set('dictName',this.dictName);
    ajax.set('disTypeNo',this.disTypeNo);
    ajax.set('dictValues',this.mutiString);
    ajax.start();
};
